package com.zx.web.repository;

import com.base.web.common.BaseRepository;
import com.zx.web.entity.SysUser;

import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

//import javax.persistence.LockModeType;
//import org.springframework.data.domain.Page;
//import org.springframework.data.domain.Pageable;
//import org.springframework.data.jpa.repository.Lock;
//import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Repository：用户表.
 * @author Ken
 * @since 2017-04-23 22:41
 * @version v1.0.0
 */
public interface SysUserRepository extends BaseRepository<SysUser, String> {

    /**
     * 根据编号查询单个对象
     */
    @Query("select * from SysUser where username = ?1")
    // @Query("select * from sys_user where username = ?1")
    SysUser findOne(String id);

    /**
     * 根据编号列表查询对象列表
     * @param ids 编号列表（逻辑主键）
     */
    @Query("select * from SysUser where username in (?1)")
    // @Query("select * from sys_user where username in (?1)")
    public List<SysUser> findList(List<String> ids);

    /**
     * 根据编号逻辑删除
     * @param id （逻辑主键）
     */
    // @Transactional
    @Modifying
    @Query("delete from SysUser where username = ?1 ")
    // @Query("delete from sys_user where username = ?1 ")
    public void delete(String id);
}
